define(["servers"], function (servers) {
    return  Backbone.Model.extend({
        defaults: function () {
            return {
            };
        },
        getPageList:function(param){
            var self = this;
            servers.media.pageList(param,function(res){
                self.set({dataPageList: res});
                self.trigger('bind:PageList');
            });
        },
        getDropDownList:function () {
            var self = this;
            servers.media.list(function(res){
                res.data=res.success ? $.ExtCommon.convertListByPara(res.data) : [];
                self.set({dataDropDownMedia: res});
                self.trigger('bind:DropDownMedia');
            });
        },
        getInfo: function (id) {
            var self = this;
            if (id) {
                servers.media.info(id, function (res) {
                    res.data=res.success?self.getMappingToWeb(res.data):{};
                    self.set({dataInfo: {isAdd:false,res:res}});
                    self.trigger('bind:Info');
                });
            } else {
                var dataDef=self.getMappingToWeb({});
                self.set({dataInfo:{isAdd:true,res:servers.getSendSuccess(dataDef)}});
                self.trigger('bind:Info');
            }
        },
        deleteInfo: function (id) {
            var self = this;
            servers.media.delete(id,function (res) {
                self.set({dataDelete: res});
                self.trigger('save:Delete');
            });
        },
        addInfo: function (json) {
            var self = this;
            var data=this.getMappingToServer(json);
            servers.media.add(data, function (res) {
                self.set({dataSave: {isAdd: true, req: json, res: res}});
                self.trigger('save:Info');
            });
        },
        updateInfo: function (json) {
            var self = this;
            var data=this.getMappingToServer(json);
            data.id=json.id;
            servers.media.update(data, function (res) {
                self.set({dataSave: {isAdd: false, req: json, res: res}});
                self.trigger('save:Info');
            });
        },
        getMappingToWeb:function(json){
            var newJson=json;
            return newJson
        },
        getMappingToServer:function(json){
            var newJson= json;
            return newJson
        }
    });
});